package edu.zqu.course.framework.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.ProcessInstance;

/**
 * @Author 郭泽鹏
 * @Date 2020/6/21 15:00
 * @Description:
 * @Version 1.0
 */

public class ActivitiStartInstance {
    public static void main(String[] args) {
        /**
         * 1.得到ProcessEngine对象
         */
        ProcessEngineConfiguration configuration = ProcessEngineConfiguration
                .createProcessEngineConfigurationFromResource("activiti/activiti.cfg.xml","processEngineConfiguration");
        ProcessEngine processEngine = configuration.buildProcessEngine();
        /**
         * 2.得到RunService
         */
        RuntimeService runtimeService =  processEngine.getRuntimeService();
        /**
         * 3.创建流程实例，流程定义的key需要知道holiday
         */
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("holiday");

        /**
         * 输出processInstance相关信息
         */
        System.out.println("流程部署ID"+processInstance.getDeploymentId());
        System.out.println("实例ID"+processInstance.getId());
        System.out.println("实例ID"+processInstance.getBusinessKey());

    }
}
